package com.sinovatech.unicom.push.aes;

public class AesUtil {
	private static final String iv = "00e5d201c2c2acbff8154861242ba0c4";// 向量
	private static final String key = "6206c34e2186e752c74e6df32ab8fa5b";// 密钥

	/**
	 * @功能:加密
	 * @param str
	 * @return
	 */
	public static String aesEncrypt(String str) {
		return EncodeUtils.hexEncode(Cryptos.aesEncrypt(str.getBytes(),
				EncodeUtils.hexDecode(key), EncodeUtils.hexDecode(iv)));
	}

	/**
	 * @功能:解密
	 * @param str
	 * @return
	 */
	public static String aesDecrypt(String str) {
		return Cryptos.aesDecrypt(EncodeUtils.hexDecode(str),
				EncodeUtils.hexDecode(key), EncodeUtils.hexDecode(iv));
	}

	public static void main(String[] args) {
		// 密钥
		//System.out.println(Cryptos.generateAesKey());
		// 向量
		//System.out.println(Cryptos.generateAesKey());
		// 密钥
		//[B@77556fd
		// 向量
		//[B@2c13da15
		//String phone = "13824963232"; //814096bbeb610ded99029aad0afa8e8b
		String phone = "15999955508"; //814096bbeb610ded99029aad0afa8e8b
		String mp = "Ns5us9GnucVpdP+HtVz4UyooFKxUhalTA8BSMpwjusHNitMlI1i698X/iAx9W4livKsSQwqBTSHQ/u7XIApbBSjDvLVnWntqU+Cs1TNFB0XBxrqCzcErSHcJ/osxr6hZTAh3iQcBPVENQNU1g++WYJvP5ygU0TQgRMo7msbaUkg="; //814096bbeb610ded99029aad0afa8e8b
		String myPuppy = aesEncrypt(phone);
		System.out.println(myPuppy);
		String dddd = aesDecrypt(mp);
		System.out.println(dddd);
		System.out.println(Hex.decodeHex(iv.toCharArray()));
		System.out.println(Hex.decodeHex(key.toCharArray()));
	}

}
